﻿function addCookie(domain,webname){　 // 加入收藏夹
	if (document.all){
		window.external.addFavorite(domain,webname);
	}else if (window.sidebar){
		window.sidebar.addPanel(domain,webname, "");
	}
}

function setHomepage(domain){　 // 设置首页
	if (document.all){
		document.body.style.behavior = 'url(#default#homepage)';
		document.body.setHomePage(domain);
	}else if (window.sidebar){
		if (window.netscape){
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch (e) {
				alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
			}
		}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage', domain);
	}
}
function fWeather(style,sWith,sHeight)
{
	document.getElementById('weather01').innerHTML='<IFRAME src="/services/?s=weather&style='+style+'" frameBorder="0" width="'+sWith+'" height="'+sHeight+'" ALIGN="CENTER" MARGINWIDTH="0" MARGINHEIGHT="0" HSPACE="0" VSPACE="0" SCROLLING="NO" allowtransparency="true"></IFRAME>'
}
function fQnav(postPath)
{
	if(window.screen.width>1200)
	{
	document.write('<div id="qnav" class="qnav">');
	document.write('<ul>');
	document.write('<li id="liGoTop"><img src="/images/qnav_1.gif" width="35" height="35" alt="返回顶部" title="返回顶部" onclick="document.documentElement.scrollTop=0;document.body.scrollTop=0" /></li>');
	document.write('<li><a href="/favorite/"><img src="/images/qnav_3.gif" width="35" height="35" alt="查看收藏" title="查看收藏" /></a>\r\n</li>');
	document.write('<li><a href="'+postPath+'"><img src="/images/qnav_4.gif" width="35" height="35" alt="发布信息" title="发布信息" /></a>\r\n</li>');
	document.write('<li id="liGoBottom"><img src="/images/qnav_2.gif" width="35" height="35" alt="返回底部" title="返回底部" onclick="document.documentElement.scrollTop=document.documentElement.scrollHeight;document.body.scrollTop=document.body.scrollHeight" />\r\n</li>');
	document.write('</ul>');
	document.write('</div>');
	_q("qnav").style.left=window.screen.width/2+500+"px";
	window.onresize=function()
	{
		if(document.body.clientWidth>1100)
		{
			_q("qnav").style.display='block';
			_q("qnav").style.left=window.screen.width/2+500+"px";
		}
		else
		{
			_q("qnav").style.display='none';	
		}
	}
	
	tnImg=_q("qnav").getElementsByTagName("img");
	for(i=0;i<tnImg.length;i++)
	{
		tnImg[i].onmouseover=function()
		{
			this.style.top="2px";
			this.style.left="2px";
		}
		tnImg[i].onmouseout=function()
		{
			this.style.top="0px";
			this.style.left="0px";
		}
	}
	}
}

function actionBaidu()
{
	_q("search_suggest").style.display="none";
	if(_q("txtSearch").vlaue!="")
	{
		window.open("http://www.baidu.com/s?wd="+_q("txtSearch").value)
	}
	else
	{
		alert("请输入关键字！");
	}
}

//收藏信息功能
function fInfoFav(id)
{
	var idStr=getCookie("favorite");
	if(idStr!=null)
	{
		idStrArr=idStr.split(",");
		for(i=0;i<idStrArr.length;i++)
		{
			if(idStrArr[i]==id)
			{
				fCleInfoFav(id);
				alert("收藏取消！");
				return;
			}
		}
		idStr=id+","+idStr;
		setCookie("favorite",idStr);
		alert("收藏成功\n收藏功能只对此电脑有效！");
	}
	else
	{
		idStr=id
		setCookie("favorite",idStr);
		alert("收藏成功\n收藏功能只对此电脑有效！");
	}
	
	
}
function fCleInfoFav(id)
{
	var idStr=getCookie("favorite");
	if(idStr!=null)
	{
		idStrArr=idStr.split(",");
		idStr="";
		for(i=0;i<idStrArr.length;i++)
		{
			if(idStrArr[i]!=id)
			{
				if(idStr=="")
				{
					idStr=idStrArr[i];
				}
				else
				{
					idStr+=","+idStrArr[i];
				}
			}
		}
		setCookie("favorite",idStr);
		if(_q("info"+id)!=null)
		{
			_q("info"+id).style.display="none";
		}
	}	
}
function setCookie(name,value)
{
	var Days = 30; 
	var exp = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";path=/;expires=" + exp.toGMTString();
}
function getCookie(name)    
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return "";
}
//收藏信息功能结束


function checktel(tel)
{
    window.open("/cha/?s="+tel);
}
function changedisplaytype(s)
{
	var dt=new Date();
	dt.setTime(dt.getTime()+365*24*60*60*1000);
	document.cookie="displaytype="+s+";expires="+dt.toGMTString();
	window.location.reload();
}
function acForm(sReUrl)
{
    var sm1=document.getElementById("m1").value;
    sm1=sm1.replace(/[\s]/,"")
    var sm2=document.getElementById("m2").value;
    sm2=sm2.replace(/[\s]/,"")
    if(sm1=="" && sm2=="")
    {
        
            window.location.replace(sReUrl.replace("MU","0"));
            return "0";
    }
    if(sm1==""||!/^\d+[.\d]*$/.test(sm1))
    {
        alert("请输入数字！");
    }
    else
    {
        if(sm2==""||!/^\d+[.\d]*$/.test(sm2))
        {
            alert("请输入数字！");
        }
        else
        {
            var m=sm1+"_"+sm2;
            window.location.replace(sReUrl.replace("MU",m));
        }
    }
    
}

function acFormCl(sReUrl)
{
            window.location.replace(sReUrl.replace("MU",0));
}

function ajaxTel(tel,obj)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
 		 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
    		document.getElementById(obj).innerHTML=xmlhttp.responseText;
    	}
  	}
	xmlhttp.open("GET","/action/?s=cha&k="+tel,true);
	xmlhttp.send();
}
function fTelSeth(obj)
{
	window.open("/search/index.aspx?s=1&w="+obj.innerHTML);
}
function fTelInfo(obj,ac)
{
	if(ac==1)
	{
		var xd = getElementPos(obj);
		_q("telInfo").style.display="block";
		_q("telInfo").style.top=(18+xd.y)+"px";
		_q("telInfo").style.left=(xd.x-35)+"px";
		_q("telInfo").innerHTML="手机资料载入中……";
		var xmlhttp;
		if (window.XMLHttpRequest)
  		{// code for IE7+, Firefox, Chrome, Opera, Safari
  			xmlhttp=new XMLHttpRequest();
  		}
		else
  		{// code for IE6, IE5
 		 	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  			if (xmlhttp.readyState==4 && xmlhttp.status==200)
    		{
    			document.getElementById("telInfo").innerHTML="<span>所在地：</span>"+xmlhttp.responseText;
    		}
  		}
		xmlhttp.open("GET","/action/?s=cha&c=1&k="+obj.innerHTML,true);
		xmlhttp.send();
	}
	if(ac==2)
	{
		_q("telInfo").style.display="none";
		_q("telInfo").style.top="-100px";
		_q("telInfo").style.left="-100px";
	}
}

function _q(obj)
{
	return document.getElementById(obj);
}


function getElementPos(elementId){     
    var ua = navigator.userAgent.toLowerCase();     
    var isOpera = (ua.indexOf('opera') != -1);     
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof     
    var el = elementId;     
    if (el.parentNode === null || el.style.display == 'none') {     
        return false;     
    }     
    var parent = null;     
    var pos = [];     
    var box;     
    if (el.getBoundingClientRect) //IE     
    {     
        box = el.getBoundingClientRect();     
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);     
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);     
        return {     
            x: box.left + scrollLeft,     
            y: box.top + scrollTop     
        };     
    }     
    else     
        if (document.getBoxObjectFor) // gecko         
        {     
            box = document.getBoxObjectFor(el);     
            var borderLeft = (el.style.borderLeftWidth) ? parseInt(el.style.borderLeftWidth) : 0;     
            var borderTop = (el.style.borderTopWidth) ? parseInt(el.style.borderTopWidth) : 0;     
            pos = [box.x - borderLeft, box.y - borderTop];     
        }     
        else // safari & opera         
        {     
            pos = [el.offsetLeft, el.offsetTop];     
            parent = el.offsetParent;     
            if (parent != el) {     
                while (parent) {     
                    pos[0] += parent.offsetLeft;     
                    pos[1] += parent.offsetTop;     
                    parent = parent.offsetParent;     
                }     
            }     
            if (ua.indexOf('opera') != -1 || (ua.indexOf('safari') != -1 && el.style.position == 'absolute'))  
  
{     
                pos[0] -= document.body.offsetLeft;     
                pos[1] -= document.body.offsetTop;     
            }     
        }     
    if (el.parentNode) {     
        parent = el.parentNode;     
    }     
    else {     
        parent = null;     
    }     
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled  
  
ancestors     
        pos[0] -= parent.scrollLeft;     
        pos[1] -= parent.scrollTop;     
        if (parent.parentNode) {     
            parent = parent.parentNode;     
        }     
        else {     
            parent = null;     
        }     
    }     
    return {     
        x: pos[0],     
        y: pos[1]     
    };     
}

function fQQTalk(qq)
{
	window.open("tencent://message/?uin=" + qq + "&Site=&Menu=yes");
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 
{ 
    var arVersion = navigator.appVersion.split("MSIE") 
    var version = parseFloat(arVersion[1]) 
    if ((version >= 5.5) && (document.body.filters)) 
    { 
       for(var j=0; j<document.images.length; j++) 
       { 
          var img = document.images[j] 
          var imgName = img.src.toUpperCase() 
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
          { 
             var imgID = (img.id) ? "id='" + img.id + "' " : "" 
             var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle 
             if (img.align == "right") imgStyle = "float:right;" + imgStyle 
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
             var strNewHTML = "<span " + imgID + imgClass + imgTitle 
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
             img.outerHTML = strNewHTML 
             j = j-1 
          } 
       } 
    }     
} 

